﻿<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>用户中心-个人资料</title>
    <link type="text/css" rel="stylesheet" href='<%=Url.Content("~/Content/homeview/css/basic.css") %>' />
    <link type="text/css" rel="stylesheet" href='<%=Url.Content("~/Content/homeview/css/user-manager.css") %>' />
    <script type="text/javascript" language="javascript" src=' <%=Url.Content("~/Scripts/jquery-1.4.4.min.js") %>'></script>
    <script type="text/javascript" language="javascript" src=' <%=Url.Content("~/Scripts/common.js") %>'></script>
    <script type="text/javascript" src='<%=Url.Content("~/Scripts/jquery.form.js") %>'></script>
    <script type="text/javascript" language="javascript" src=' <%=Url.Content("~/Scripts/jquery.validate.js") %>'></script>

    <script type="text/javascript">
        $(function() {
            ///验证
            var userForm = $("#personalInfo");
            userForm.validate({
                rules: {
                    username: {
                        required: true,
                        minlength: 2,
                        remote: {
                            url: "../UserCenter/VerifyUserName",     //后台处理程序 
                            type: "post",               //数据发送方式 
                            dataType: "json"           //接受数据格式    
                        }
                    },
                    pwd: {
                        required: true,
                        minlength: 6
                    },
                    repwd: {
                        equalTo: "#pwd"
                    },
                    code: {
                        required: true
                    }
                }
            });
        });
        function insert() {
            var userform = $("#personalInfo");
            if (userform.validate().form()) {
                var username = $("#username").val();
                var userpwd = $("#pwd").val();
                var imgcode = $("#code").val();
                $.ajax({
                    datatype: "text",
                    type: "Post",
                    url: "../UserCenter/InsertUser",
                    data: {
                        username: username,
                        userpwd: userpwd,
                        imgcode: imgcode
                    },
                    success: function(data) {
                    if (data == "1") {
                            window.location.href = "../userCenter/UserDetail";
                        } else {
                            alert(data);
                        }
                    },
                    error: function(data) {
                        alert("发生未知错误，注册失败！请您稍后再试！");
                    }
                });
            }
        }
        function changeImg(t) {
            var a = $(t);
            $.ajax({
                datatype: "text",
                type: "Post",
                url: "../UserCenter/GetImgCode",
                success: function(data) {
                    if (data == "0") {
                        alert("对不起，发生未知错误，获取图片失败！请您稍后再试！");
                    } else {
                        a.siblings("#code").attr("src", data);
                    }
                }
            });
        }
    </script>

</head>
<body>
    <!-- header start-->
    <div id="header">
        <div id="headerInner">
            <h1 id="logo">
                <a href="##">桂林最大生活信息门户</a></h1>
        </div>
    </div>
    <!-- header end-->
    <div id="conContainer" class="grid-main clearfix">
        <div id="primaryContent" class="grid-c2 fl-r">
            <div class="primary-inner">
                <!--个人资料管理开始-->
                <form id="personalInfo">
                <!--修改资料-->
                <fieldset class="xiugai-data">
                    <legend>用户注册 </legend>
                    <h2>
                        注册资料</h2>
                    <ul>
                        <li class="clearfix data-f">
                            <label for="txtusername">
                                用户名：</label>
                            <input type="text" id="username" name="username" />
                        </li>
                        <li class="clearfix data-f">
                            <label for="txtPwd">
                                密码：</label>
                            <input type="password" id="pwd" name="pwd" />
                        </li>
                        <li class="clearfix data-f">
                            <label for="txtRepwd">
                                确认密码：</label>
                            <input type="password" id="repwd" name="repwd" />
                        </li>
                        <li class="clearfix data-f">
                            <label for="txtcode">
                                验证码：</label>
                            <input type="text" id="code" name="code" />
                        </li>
                        <li class="clearfix data-f">
                            <label for="txtcode">
                            </label>
                            <a href="javascript:void()" onclick="changeImg(this)">看不清</a>
                            <img id="code" style="padding-right: 8px" src='<%=ViewData["imgcode"]%>' />
                        </li>
                    </ul>
                </fieldset>
                <!--提交修改-->
                <fieldset class="submit">
                    <input class="submit" type="button" onclick="insert()" value="提交" />
                </fieldset>
                </form>
                <!--个人资料管理结束-->
            </div>
        </div>
    </div>
    <!-- footer start-->
    <div id="footer">
        <p style="font-family: Verdana,Geneva,sans-serif;">
            Copyright &copy; 2011-2100 Eelly.All Rights Reserved</p>
        <p>
            逍遥游 版权所有</p>
        </sapn>
    </div>
    <!-- footer end-->
</body>
</html>
